(function($){
	$.fn.gridTitleEditor = function(options, param){
		if (typeof options == "string") return $.fn.gridTitleEditor.methods[options](this, param);
		options = options || {};
		return this.each(function(){
			var state = $.data(this, "gridTitleEditor");
			if (state) {
				$.extend(state.options, options);	//将新的属性元素覆盖
			} else {
				$.data(this, "gridTitleEditor", $.extend({},$.fn.gridTitleEditor.default,options));
				create(this);
			}
		});
	};
	function create(target) {
		$("head").append("\
<style type='text/css'>\
.gridTitleEditor{overflow:hidden;}\
.gridTitleEditor *{padding:0;margin:0;font-size:12px;}\
.gridTitleEditor>div{float:left;box-sizing:border-box;overflow:hidden;position:relative;}\
.gridTitleEditor-tablt{border-right:1px solid #d3d3d3;border-bottom:1px solid #d3d3d3;background:#fafafa;}\
.gridTitleEditor-rowDiv{border-bottom:1px solid #d3d3d3;background:#fafafa;}\
.gridTitleEditor-colDiv{border-right:1px solid #d3d3d3;background:#fafafa;}\
.gridTitleEditor-tabBox{overflow:auto!important;}\
.gridTitleEditor table{border-spacing:0;border-collapse:collapse;}\
.gridTitleEditor td{cursor:default;box-sizing:border-box;}\
.gridTitleEditor-rowDiv td{border-right:1px solid #d3d3d3;}\
.gridTitleEditor-rowDiv td:last-child{border-right:0;}\
.gridTitleEditor-colDiv td{border-bottom:1px solid #d3d3d3;}\
.gridTitleEditor-colDiv tr:last-child>td{border-bottom:0;}\
.gridTitleEditor-tabBox td{border-right:1px solid #d3d3d3;border-bottom:1px solid #d3d3d3;}\
.gridTitleEditor-frozen{border-right:1px solid #f00!important;}\
.gridTitleEditor td>span{display:inline-block;vertical-align:middle;text-align:left;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;outline-width:0;}\
.gridTitleEditor-tabBox td>span.selected{background:#eef5ff;}\
.gridTitleEditor-resize{position:absolute;background:#bbb;width:6px;display:none;cursor:col-resize;}\
.gridTitleEditor-input{position:absolute;border:1px solid #61CFEB;box-sizing:border-box;background:#fff;display:none;outline-width:0;overflow:hidden;}\
.gridTitleEditor-colDiv tr.selected{background: #d81e06;color: white;}\
</style>");
		var $target = $(target).addClass("gridTitleEditor"), opt = $.data(target,"gridTitleEditor"), vm = opt.vm = {
			ltDiv:$("<div class='gridTitleEditor-tablt'></div>").appendTo(target), //tab左上角空白处
			rowDiv:$("<div class='gridTitleEditor-rowDiv'><table></table></div>").appendTo(target), //行标题区域
			colDiv:$("<div class='gridTitleEditor-colDiv'><table width='100%'></table></div>").appendTo(target), //列标题区域
			tabBox:$("<div class='gridTitleEditor-tabBox'><table></table></div>").appendTo(target), //主内容表格区域
			tmp:$("<c style='position:absolute;left:-10000px;line-height:"+opt.cellHeight+"px'></c>").appendTo(target)
		};
		vm.tab = vm.tabBox.children();
		target.onselectstart = function(){if (event.srcElement.tagName!="TEXTAREA") return false;};
		initPluginSize($target, opt);
		vm.tab.delegate("span","mousedown",function(e){ //选中单元格
			vm.selectedTd = e.target;
		}).delegate("span","focus",function(e){ //单元格获取焦点，点击或tab键皆可触发
			vm.tab.find("span.selected").removeClass("selected");
			var td = $(e.target).addClass("selected");
			vm.selArea = {x1:Number(td.attr("l")),y1:Number(td.attr("t")),x2:Number(td.attr("r")),y2:Number(td.attr("b"))};
		}).delegate("span","mouseenter",function(e){ //合并单元格的滑动移入处理
			if (!vm.selectedTd || e.target==vm.selectedTd) return;
			//vm.selectedTd.blur();
			var td1 = vm.selectedTd, td2 = e.target, mer = $.extend(true,[],vm.merge),
				x1 = Math.min(Number(td1.getAttribute("l")),Number(td2.getAttribute("l"))),
				x2 = Math.max(Number(td1.getAttribute("r")),Number(td2.getAttribute("r"))),
				y1 = Math.min(Number(td1.getAttribute("t")),Number(td2.getAttribute("t"))),
				y2 = Math.max(Number(td1.getAttribute("b")),Number(td2.getAttribute("b")));
			for (var i=0; i<mer.length; i++){
				var m = mer[i], c = false;
				if (Math.min(m.x2,x2)-Math.max(m.x1,x1)>=0 && Math.min(m.y2,y2)-Math.max(m.y1,y1)>=0){ //相交
					if (x1>m.x1) {x1 = m.x1; c = true;}
					if (x2<m.x2) {x2 = m.x2; c = true;}
					if (y1>m.y1) {y1 = m.y1; c = true;}
					if (y2<m.y2) {y2 = m.y2; c = true;}
					if (c) {mer.splice(i,1); i = -1};
				}
			}
			vm.selArea = {x1:x1,x2:x2,y1:y1,y2:y2};
			vm.tab.find("span.selected").removeClass("selected");
			for (var i=y1; i<=y2; i++) for (var j=x1;j<=x2; j++) $("#gridTitleEditor_cell_"+j+"_"+i).addClass("selected");
		}).delegate("span","dblclick",function(e){ //双击编辑
			editCell($(e.target));
		}).delegate("span","keyup",function(e){ //内容输入处理
			if (e.keyCode==9) return; //tab键
			else if (e.keyCode==46) vm.tab.find("span.selected").each(function(){setCellVal($(this), "", opt);}); //delete键
			else editCell($(e.target));
		});
		vm.colDiv.delegate("tr","click",function(){
			vm.colDiv.find("tr.selected").removeClass("selected").find("input").remove();
			vm.selectedCol = this;
			$("<input style='width:0;height:0;border:none;'/>").appendTo($(this).addClass("selected")).focus();
		}).delegate("input","paste",function(e){
			if(window.clipboardData)
				return;
			var data = e.originalEvent.clipboardData.getData("text");//获取文本
			var code = e.originalEvent.clipboardData.getData("text/html");//获取格式
			if(!data||!code) return;
			var data = data.split("\n");//分隔行
			if($(vm.selectedCol).index() !=0)//选中的不是第一行
				vm.colDiv.find("tr:first").click();
			for(var j=0;j<data.length;j++){
				var p = data[j];
				if(!p) continue;
				var tr = vm.tab.find("tr").eq($(vm.selectedCol).index());
				var text = p.split("\t");
				for(var i=0;i<text.length;i++){
					if(!text[i].trim()) continue;
					setCellVal(tr.children().children("span").eq(i),text[i].trim().replace("\n",""),opt);
				}
				$(vm.selectedCol).next().click();
			}
			$(code).find("tr").each(function(idx){
				var tr = vm.tab.find("tr").eq(idx);//跨行全合并无法解析
				$(this).children("td").each(function(idx1){
					var c = $(this).attr("colspan"),r = $(this).attr("rowspan");
					var td = tr.children().children("span").eq(idx1);
					opt.vm.selArea = {x1:Number(td.attr("l")),y1:Number(td.attr("t")),x2:Number(td.attr("l"))+Number(c||1) -1,y2:Number(td.attr("t"))+Number(r||1)-1};
					merge(opt.vm);
				});
			});
		});
		function editCell(td){
			var pos = td.offset(), pos2 = vm.tabBox.offset(), w = td[0].scrollWidth, h = td.height();
			var r = pos2.left + vm.tabBox[0].clientWidth, b = pos2.top + vm.tabBox[0].clientHeight;
			if (pos.left+w > r) w = r - pos.left;
			if (pos.top+h > b) h = b - pos.top;
			vm.input.show().offset({left:pos.left-1,top:pos.top-1}).val(td[0].innerText).width(w).height(h).focus().attr("tabindex",td.attr("tabindex")).data("target",td);
		}
		vm.rowDiv.children().delegate("span","mousemove",function(e){ //表头调整列宽处理
			if (vm.colResizeStart || vm.selectedTd) return;
			var td = $(e.target), pos = td.offset();
			if (pos.left + td.outerWidth() - e.pageX > 3) vm.colResize.hide();
			else vm.colResize.show().height(td.outerHeight()).offset({left:pos.left + td.outerWidth()-4,top:pos.top}).data("target",td);
		});
		vm.colResize = $("<span/>").appendTo(target).addClass("gridTitleEditor-resize").mousedown(function(e){
			vm.colResizeStart = true;
		}).mouseout(function(e){
			if (vm.colResizeStart) return;
			vm.colResize.hide();
		});
		vm.input = $("<textarea class='gridTitleEditor-input' wrap='off'></textarea>").appendTo(vm.tabBox).css({lineHeight:opt.cellHeight+"px"}).blur(function(e){
			var td = $.data(this,"target"), val = $(this).hide().val().trim().replace(/\n/g,"<br>").replace(/ /g,"&nbsp;");
			setCellVal(td, val, opt);
			$.removeData(this,"target");
		}).keyup(function(e){
			var o = $(this), p1 = o.offset(), p2 = vm.tabBox.offset(), r = p2.left + vm.tabBox[0].clientWidth, b = p2.top + vm.tabBox[0].clientHeight;
			if (this.offsetWidth<this.scrollWidth) if (this.scrollWidth+p1.left<r) o.width(this.scrollWidth); else o.width(r-p1.left-2);
			if (this.offsetHeight<this.scrollHeight) if (this.scrollHeight+p1.top<b) o.height(this.scrollHeight); else o.height(b-p1.top-2);
		});
		$(window).bind("mouseup",function(e){ //单元格滑动结束处理
			vm.selectedTd = null;
		}).bind("mousemove",function(e){ //列宽设置移动处理
			if (!vm.colResizeStart) return;
			vm.colResize.offset({left:e.pageX});
		}).bind("mouseup",function(e){ //列宽设置移动结束处理
			if (!vm.colResizeStart) return;
			vm.colResize.hide();
			vm.colResizeStart = false;
			var td = vm.colResize.data("target"), ow = td.width(), w = e.pageX-td.offset().left;
			if (w < opt.minCellWidth) w = opt.minCellWidth; //列最小宽度
			var os = w - ow; //偏移量
			if (Math.abs(os) < 3) return; //移动3像素以内忽略
			setCellWidth(Number(td.text()), os, vm);
		});
		vm.tabBox.scroll(function(e){ //行列跟随滚动
			if (vm.input.is(":visible")) {
				var p = vm.input.data("target").offset();
				vm.input.offset({left:p.left-1,top:p.top-1});
			};
			vm.rowDiv.scrollLeft(vm.tabBox.scrollLeft());
			vm.colDiv.scrollTop(vm.tabBox.scrollTop());
		});
		$target.gridTitleEditor("loadConfig",opt.config);
		delete opt.config;
	}
	function setCellVal(td, val, opt){
		td.html(val);
		var os = cellMinHeight(td) - td.height();
		if (os != 0) { //需要修改行高度
			var tr = td.parent().parent(), y = Number(td.attr("t"));
			if (os < 0) { //行高降低，需计算该行所有单元格高度，取可减少的最小值
				var h1 = Math.abs(os);
				tr.find("span").each(function(){
					var o = $(this), h2 = o.height() - cellMinHeight(o);
					if (h1 > h2) h1 = h2;
				});
				for (var i=0; i<opt.vm.merge.length; i++){
					if (y>opt.vm.merge[i].y1 && y<=opt.vm.merge[i].y2) {
						var o = $("#gridTitleEditor_cell_"+opt.vm.merge[i].x1+"_"+opt.vm.merge[i].y1), h2 = o.height() - cellMinHeight(o);
						if (h1 > h2) h1 = h2;
					}
				}
				os = -h1;
			}
			if (os != 0) { //需要修改行高度
				//行号表格中单元格高度调整
				var o = $("#gridTitleEditor_row_"+y);
				o.height(o.height() + os);
				//该行所有单元格高度调整
				tr.find("span").each(function(){
					o = $(this);
					o.height(o.height() + os);
				});
				//与该行相交的所有合并单元格高度调整
				for (var i=0; i<opt.vm.merge.length; i++){
					if (y>opt.vm.merge[i].y1 && y<=opt.vm.merge[i].y2) {
						o = $("#gridTitleEditor_cell_"+opt.vm.merge[i].x1+"_"+opt.vm.merge[i].y1);
						o.height(o.height() + os);
					}
				}
			}
		}
		if (val!=""){
			if (opt.x==td.attr("r")){ //加列
				opt.x++;
				opt.vm.tab.find("tr").each(function(idx){
					$(this).append(createTabCell(opt.x,idx+1,opt.cellWidth,$("#gridTitleEditor_row_"+(idx+1)).height()));
				});
				$("#gridTitleEditor_rScroll").parent().before(createRowCell(opt.x,opt.cellWidth,opt.cellHeight));
			}
			if (opt.y==td.attr("b")){ //加行
				opt.y++;
				var tr = "<tr>";
				for (var i=1; i<=opt.x; i++) tr += createTabCell(i,opt.y,$("#gridTitleEditor_col_"+i).width(),opt.cellHeight,opt.vm.frozen==i);
				opt.vm.tab.append(tr+"</tr>");
				$("#gridTitleEditor_cScroll").parent().parent().before(createColCell(opt.y,opt.cellHeight));
			}
		}
		setScroll(opt.vm.tabBox[0]);
		function cellMinHeight(td){
			var rowspan = Number(td.parent().attr("rowspan")||1);
			return Math.max(opt.vm.tmp.html(td[0].innerHTML).height(), opt.cellHeight * rowspan + rowspan - 1);
		}
	}
	function initPluginSize(target,opt){
		var cellW = cellH = opt.cellHeight, w = target.width(), h = target.height();
		opt.vm.ltDiv.css({width:cellW,height:cellH});
		opt.vm.rowDiv.css({width:w-cellW,height:cellH});
		opt.vm.colDiv.css({width:cellW,height:h-cellH});
		opt.vm.tabBox.css({width:w-cellW,height:h-cellH});
	}
	function initTab(opt, size){
		if (!size) size = $.fn.gridTitleEditor.tabSize;
		else {
			if (size.x<$.fn.gridTitleEditor.tabSize.x) size.x = $.fn.gridTitleEditor.tabSize.x;
			if (size.y<$.fn.gridTitleEditor.tabSize.y) size.y = $.fn.gridTitleEditor.tabSize.y;
		}
		$.extend(opt, size);
		$.extend(opt.vm,{selectedTd:null,merge:[],selArea:{},frozen:0});
		var tab = "", rtab = "<tr>", ctab = "";
		for (var i=1; i<=opt.y; i++){
			tab += "<tr>";
			for (var j=1; j<=opt.x; j++){
				if (i==1) rtab += createRowCell(j,opt.cellWidth,opt.cellHeight);
				tab += createTabCell(j,i,opt.cellWidth,opt.cellHeight);
			}
			tab += "</tr>";
			ctab += createColCell(i,opt.cellHeight);
		}
		opt.vm.rowDiv.children().empty().append(rtab+"<td><div id='gridTitleEditor_rScroll'></div></td></tr>");
		opt.vm.colDiv.children().empty().append(ctab+"<tr><td><div id='gridTitleEditor_cScroll'></div></td></tr>");
		opt.vm.tab.empty().append(tab);
		setScroll(opt.vm.tabBox[0]);
	}
	function createTabCell(x,y,w,h,frozen){
		return "<td"+(frozen?" class='gridTitleEditor-frozen'":"")+"><span id='gridTitleEditor_cell_"+x+"_"+y+"' l='"+x+"' t='"+y+"' r='"+x+"' + b='"+y+"' tabindex='"+(y*1000+x)+"' style='width:"+w+"px;height:"+h+"px;line-height:"+h+"px;'></span></td>";
	}
	function createRowCell(x,w,h){
		return "<td><span id='gridTitleEditor_col_"+x+"' style='text-align:center;width:"+w+"px;height:"+h+"px;line-height:"+h+"px;'>"+x+"</span></td>";
	}
	function createColCell(y,h){
		return "<tr><td align='center'><span id='gridTitleEditor_row_"+y+"' style='height:"+h+"px;line-height:"+h+"px;'>"+y+"</span></td></tr>";
	}
	function setScroll(tabBox){
		$("#gridTitleEditor_rScroll").width(tabBox.offsetWidth-tabBox.clientWidth);
		$("#gridTitleEditor_cScroll").height(tabBox.offsetHeight-tabBox.clientHeight);
	}
	function merge(vm){
		if (!vm.selArea || (vm.selArea.x1==vm.selArea.x2 && vm.selArea.y1==vm.selArea.y2)) return;
		if (vm.frozen>=vm.selArea.x1 && vm.frozen<vm.selArea.x2) return; //在冻结列之间
		var d = vm.selArea, tds = vm.tab.find(".selected"), flag = tds.length>0;
		if (!flag) { //没选择项，从合并区域中添加所有单元格
			for (var i=d.y1; i<=d.y2; i++){
				for (var j=d.x1; j<=d.x2; j++){
					var td = document.getElementById("gridTitleEditor_cell_"+j+"_"+i);
					if (td) tds.push(td);
				}
			}
		}
		var td1 = $(tds[0]), pos = td1.offset();
		var td2 = tds.filter("[t="+d.y1+"][r="+d.x2+"]"), w = td2.offset().left - pos.left + td2.width();
		var td3 = tds.filter("[b="+d.y2+"][l="+d.x1+"]"), h = td3.offset().top - pos.top + td3.height();
		tds.filter(":gt(0)").parent().remove();
		td1.attr({r:d.x2,b:d.y2}).width(w).height(h).parent().attr({rowspan:d.y2-d.y1+1,colspan:d.x2-d.x1+1});
		if (vm.frozen==d.x2) td1.parent().addClass("gridTitleEditor-frozen");
		if (flag) td1.focus();
		vm.merge = [];
		vm.tab.find("td[rowspan]").each(function(){
			var o = $(this).children()[0];
			vm.merge.push({x1:Number(o.getAttribute("l")),x2:Number(o.getAttribute("r")),y1:Number(o.getAttribute("t")),y2:Number(o.getAttribute("b"))});
		});
	}
	function setCellWidth(x, os, vm){
		var o = $("#gridTitleEditor_col_"+x); o.width(o.width() + os); //表头调整
		vm.tab.find("span[r="+x+"]").each(function(){ //该列所有单元格宽度调整
			var o = $(this); o.width(o.width() + os);
		});
		for (var i=0; i<vm.merge.length; i++){ //与该列相交的所有合并单元格宽度调整
			if (x>=vm.merge[i].x1 && x<vm.merge[i].x2) {
				var o = $("#gridTitleEditor_cell_"+vm.merge[i].x1+"_"+vm.merge[i].y1);
				o.width(o.width() + os);
			}
		}
		setScroll(vm.tabBox[0]); //重置行列滚动条占位
	}
	function getColsSize(columns){ //根据columns配置获取所占用的行、列数
		if (!columns || !columns[0].length) return null;
		var row = columns[0], ret = {x:0,y:1};
		for (var i=0; i<row.length; i++) ret.x += row[i].colspan||1;
		for (var i=0; i<columns.length; i++) {
			var n = columns[i][0].rowspan||1;
			ret.y += n;
			if (n > 1) i += n - 1;
		}
		return ret;
	}
	function loadConfig(opt,columns,frozenCols){
		var resize = []; //记录需改变列宽的列信息
		for (var i=0; i<columns.length; i++){
			var start = 0, tr = opt.vm.tab.find("tr:eq("+i+")"); //取得表格行
			if (frozenCols && frozenCols[i]) {
				start = frozenCols[i].length; //计算配置行的开始td序号
				if (!opt.vm.frozen) opt.vm.frozen = Number(tr.children(":eq("+(start-1)+")").children().attr("r")); //记录冻结列的开始
			}
			for (var j=0; j<columns[i].length; j++){
				var c = columns[i][j], td = tr.children(":eq("+(j+start)+")").children().css("textAlign",c.align||"left");
				setCellVal(td, c.title, opt);
				if (c.width && td.width()!=c.width) resize.push({x:Number(td.attr("r")),width:c.width});
				if (c.field) $("#gridTitleEditor_cell_"+td.attr("l")+"_"+(columns.length+1)).html(c.field);
				if (c.rowspan>1 || c.colspan>1){ //需合并单元格
					opt.vm.selArea = {x1:Number(td.attr("l")),y1:Number(td.attr("t")),x2:Number(td.attr("l"))+(c.colspan||1)-1,y2:Number(td.attr("t"))+(c.rowspan||1)-1};
					merge(opt.vm);
				}
			}
		}
		for (var i=0; i<resize.length; i++) setCellWidth(resize[i].x, resize[i].width-opt.cellWidth, opt.vm);
		if (opt.vm.frozen) { //有冻结列
			opt.vm.tab.find("span[r="+opt.vm.frozen+"]").parent().addClass("gridTitleEditor-frozen");
			$("#gridTitleEditor_col_"+opt.vm.frozen).parent().addClass("gridTitleEditor-frozen");
		}
	}
	$.fn.gridTitleEditor.default = {minCellWidth:30,cellWidth:80,cellHeight:22};
	$.fn.gridTitleEditor.tabSize = {x:10,y:5};
	$.fn.gridTitleEditor.methods = {
		reset:function(jq){
			return jq.each(function(){
				initTab($.data(this,"gridTitleEditor"));
			});
		},
		merge:function(jq){
			return jq.each(function(){
				merge($.data(this,"gridTitleEditor").vm);
			});
		},
		setAlign:function(jq,align){
			return jq.each(function(){
				var area = $.data(this,"gridTitleEditor").vm.selArea;
				if (area)for(var i=area.x1;i<=area.x2;i++)for(var j=area.y1;j<=area.y2;j++)$("#gridTitleEditor_cell_"+i+"_"+j).css({textAlign:align});
			});
		},
		getConfig:function(jq){
			var vm = jq.data("gridTitleEditor").vm, y = Number(vm.tab.find("span[l=1]:not(:empty):last").attr("b")); //表格配置的下边界
			if (!y) return null; //没输入
			var frozen = "", col = "", cfg = "", x = Number(vm.tab.find("span[b="+y+"]:not(:empty):last").attr("r")); //表格配置右边界
			for (var i=1; i<y; i++){
				var row1 = "", row2 = "";
				for (var j=1; j<=x; j++){
					var td = $("#gridTitleEditor_cell_"+j+"_"+i), p = td.parent();
					if (!td.length) continue;
					var str = '{title:"'+td.html()+'",align:"'+td.css("textAlign")+'"';
					if (td.attr("b")==y-1) str += ',field:"'+$("#gridTitleEditor_cell_"+j+"_"+y).text()+'"';
					if (p.attr("rowspan") && Number(p.attr("rowspan")) > 1) str += ",rowspan:"+p.attr("rowspan");
					if (p.attr("colspan") && Number(p.attr("colspan")) > 1) str += ",colspan:"+p.attr("colspan");
					else str += ",width:"+td.width();
					str += "}";
					if (j<=vm.frozen) { if (row1) row1 += ","; row1 += "\n		" + str; } //冻结列
					else { if (row2) row2 += ","; row2 += "\n		" + str; } //非冻结列
				}
				if (row1) { if (frozen) frozen += ","; frozen += "["+row1+"\n	]"; }
				if (row2) { if (col) col += ","; col += "["+row2+"\n	]"; }
				if (frozen&&!row1) frozen += ",[]";
			}
			cfg  = "{\n	"+(frozen?"frozenColumns:["+frozen+"],\n	":"")+"columns:["+col+"]\n}";
			return cfg;
		},
		loadConfig:function(jq,cfg){
			if (!cfg) cfg = {};
			return jq.each(function(){
				var opt = jq.data("gridTitleEditor"), s1 = getColsSize(cfg.columns), s2 = getColsSize(cfg.frozenColumns);
				if (s1) {
					if (s2) { s1.x += s2.x; s1.y += s2.y; }//有冻结列配置
					s1.x += 1;
					s1.y += 1;
				}
				initTab(opt, s1); // 重置表格
				if (s2) loadConfig(opt,cfg.frozenColumns);
				if (s1) loadConfig(opt,cfg.columns,cfg.frozenColumns);
			});
		},
		frozen:function(jq){
			var vm = jq.data("gridTitleEditor").vm;
			if (!vm.selArea || !vm.selArea.x1 || vm.selArea.x1==1) return false;
			for (var i=0; i<vm.merge.length; i++){ //判断该列下是否有合并单元格
				if (vm.selArea.x1>vm.merge[i].x1 && vm.selArea.x1<=vm.merge[i].x2) return false;
			}
			vm.frozen = vm.selArea.x1 - 1;
			vm.tab.find("span[r="+vm.frozen+"]").parent().addClass("gridTitleEditor-frozen");
			$("#gridTitleEditor_col_"+vm.frozen).parent().addClass("gridTitleEditor-frozen");
			return true;
		},
		unfrozen:function(jq){
			return jq.each(function(){
				var vm = jq.data("gridTitleEditor").vm;
				if (!vm.frozen) return;
				vm.tab.find(".gridTitleEditor-frozen").removeClass("gridTitleEditor-frozen");
				$("#gridTitleEditor_col_"+vm.frozen).parent().removeClass("gridTitleEditor-frozen");
				vm.frozen = 0;
			});
		},
		resize:function(jq){
			var opt = jq.data("gridTitleEditor");
			if(!opt) return;
			initPluginSize($(jq),jq.data("gridTitleEditor"));
		}
	};
})(jQuery);